import java.util.*;

public class Day_11_2_最大连续bit数 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()){
            int n = sc.nextInt();
            int count = 0;
            int s = 0;
            while (n != 0){
                if((n & 1) == 1){
                    ++s;
                    count = s > count ? s : count;
                }else {
                    s = 0;
                    n = n >> 1;
                }
            }
            System.out.println(count);
        }
    }
}
